<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateBookTypeItemTable extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $item = $this->table('book_type_item', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '知识本类型项目']);

        $item->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('book_type_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '类型ID'])
            ->addColumn('item_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '项目ID'])
            ->addColumn('item_type', 'enum', ['values' => 'normal,system', 'default' => 'normal', 'comment' => '项目类型'])
            ->addColumn('number', 'integer', ['limit' => 11, 'default' => 1, 'comment' => '排序'])
            ->addColumn("attribute", 'integer', ['limit' => 5, 'default' => 1, 'comment' => '属性:1.公开,2.私有'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('book_type_item');
    }
}
